import CallAction from "../actions/CallAction";
import { PlayerStatusManager } from "../player/StatusChecker";
import { State } from "./Fsm";

export default class BaseState extends State {
    protected btAction: bt.Sequences;
    protected btBlackBoard: bt.BlackBoard;
    constructor() {
        super();
        this.btBlackBoard = bt.BlackBoard.create();
        this.btAction = bt.Sequences.create();
        this.btAction.addNode(CallAction.create(() => {
            PlayerStatusManager.updateChecker();
        }))
    }

    protected addActions(...actions: bt.INode[]): void {
        actions.forEach(el => this.btAction.addNode(el));
    }

    onEnter(): void {
    }

    onEntryFrom(state: number): void {
    }

    onExit(): void {
    }

    onUpdate(): void {
        this.btAction.tick(this.btBlackBoard);
    }
}